package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportUploadFiles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 16:00:11
 */
@Repository
public class TransportUploadFilesDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportUploadFilesDao.class);

    public TransportUploadFiles insert(final TransportUploadFiles transportUploadFiles) {
        insert("TransportUploadFiles.insert", transportUploadFiles);
        return transportUploadFiles;
    }

    public Boolean updateInfoById(final TransportUploadFiles transportUploadFiles) {
        return update("TransportUploadFiles.updateInfoById", transportUploadFiles) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportUploadFiles.updateInfoByQuery", query) > 0;
    }

    public TransportUploadFiles selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportUploadFiles.selectById", query);
    }

    public List<TransportUploadFiles> selectByQuery(final Query query) {
        return queryForList("TransportUploadFiles.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportUploadFiles.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportUploadFiles transportUploadFiles = new TransportUploadFiles();
        transportUploadFiles.setDeleteFlag(1);
        transportUploadFiles.setId(id);
        transportUploadFiles.setEntId(entId);

        return update("TransportUploadFiles.updateInfoById", transportUploadFiles) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportUploadFiles.deleteById", query) > 0;
    }
}